﻿<UserControl x:Class="Neurotoxin.Godspeed.Shell.Views.ConnectionsPane"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:inf="clr-namespace:Neurotoxin.Godspeed.Presentation.Infrastructure;assembly=Neurotoxin.Godspeed.Presentation"
             xmlns:e="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
             xmlns:vc="clr-namespace:Neurotoxin.Godspeed.Shell.Views.Controls" 
             xmlns:lex="http://wpflocalizeextension.codeplex.com"
             lex:LocalizeDictionary.DesignCulture="en-US"
             lex:ResxLocalizationProvider.DefaultAssembly="Neurotoxin.Godspeed.Shell"
             lex:ResxLocalizationProvider.DefaultDictionary="Resources">
    <UserControl.Resources>
        <ResourceDictionary Source="/Themes/WhistlerBlue.xaml"/>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="29"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>

        <Border Grid.Row="1" Background="{Binding Path=IsActive, Converter={StaticResource PaneHeaderBackgroundConverter}}"
                BorderBrush="#FF9B9999" BorderThickness="1,1,1,0" SnapsToDevicePixels="True">
            <TextBlock Text="{lex:LocText Connections}" Padding="2" FontWeight="Bold"/>
        </Border>

        <ListBox Grid.Row="2" ItemsSource="{Binding Items}" SelectedItem="{Binding SelectedItem}" x:Name="ConnectionList"
                 ScrollViewer.HorizontalScrollBarVisibility="Disabled" BorderThickness="1">
            <ListBox.ItemsPanel>
                <ItemsPanelTemplate>
                    <WrapPanel IsItemsHost="True" Background="White"/>
                </ItemsPanelTemplate>
            </ListBox.ItemsPanel>
            <ListBox.ItemContainerStyle>
                <Style TargetType="ListBoxItem">
                    <Setter Property="Margin" Value="5,5,0,0"/>
                </Style>
            </ListBox.ItemContainerStyle>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <Grid Margin="2" Width="128" Height="Auto">
                        <Grid.RowDefinitions>
                            <RowDefinition Height="128"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <Image Grid.Row="0" Source="{Binding Thumbnail}" HorizontalAlignment="Center" VerticalAlignment="Center"/>
                        <TextBlock Grid.Row="1" Text="{Binding Name}" HorizontalAlignment="Center" TextTrimming="CharacterEllipsis"/>
                    </Grid>
                </DataTemplate>
            </ListBox.ItemTemplate>
            <e:Interaction.Triggers>
                <e:EventTrigger EventName="MouseUp">
                    <inf:MapMouseEventToCommand Command="{Binding SetActiveCommand}"/>
                </e:EventTrigger>
                <e:EventTrigger EventName="MouseDoubleClick">
                    <inf:MapMouseEventToCommand Command="{Binding ConnectCommand}"/>
                </e:EventTrigger>
                <e:EventTrigger EventName="PreviewKeyDown">
                    <inf:MapKeyboardEventToCommand Command="{Binding ConnectCommand}"/>
                </e:EventTrigger>
            </e:Interaction.Triggers>
        </ListBox>

        <vc:ProgressNotificationBar Grid.Row="2" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>

        <TextBlock Text="" Padding="2" Grid.Row="3"/>
    </Grid>
</UserControl>